/**
 * @class NG.controllers.Index
 * @extends {Ext.Controller}
 * 
 * This controller handles events and commands for first view {@link NG.views.Index} of the application.
 * 
 */
NG.controllers.Index = Ext.extend(Ext.Controller, {
	
	/**
	 * Activates workspace form due to create a new workspace
	 * So that workspace form is cleared when activated.
     * @param {Object} options
     * 		<li>caller
	 */
    newWorkspace: function(options) {
    	/*
    	app.views.workspaceForm.prepareForNewRecord();
    	app.views.workspaceForm.setCaller(options.caller);
        app.views.viewport.setActiveItem(
            app.views.workspaceForm, options.animation
        );
        */
		var panel = new App.WorkspaceFormPopupPanel({
			editable: true
		});
		panel.prepareForNewRecord();
		//panel.getForm().load(record);
		panel.show();
    	
    },

    /**
     * Activates workspace list panel.
     * When workspace list panel is activated workspaces are list on list. 
     * @param {Object} options
     */
	workspaces: function(options) {
        app.views.viewport.setActiveItem(
            app.views.workspaceList, options.animation
        );		
	},
	
	/**
	 * @param {Object} options
	 */
	toggleMapViewToolbar: function (options){
		app.views.viewport.setActiveItem(1);
		var tbar = app.views.mapView.getToolbar();
		if (tbar.isHidden()) {
			tbar.show();			
		} else {
			tbar.hide();
		}
		//app.views.mapView.doLayout();
		app.views.mapView.update();
	},
	
	/**
	 * Activates map view panel.
	 * @function map
     * @param {Object} options
	 */
	map: function(options){
        app.views.viewport.setActiveItem(
            app.views.mapView, options.animation
        );			
	}
});

/**
 * sss
 * 
 * @constant app.controllers.index
 */
app.controllers.index = new NG.controllers.Index();